var t = getApp();

Page({
    data: {
        active: 0,
        show: !1,
        points: "",
        info: [],
        withdraw_type: "",
        list: [],
        isLoadMore: !0,
        page: 1,
        total_page: 0
    },
    onLoad: function(t) {
        wx.setNavigationBarTitle({
            title: "打卡明细"
        });
    },
    initPage: function() {
        this.setData({
            list: []
        }), this.data.page = 1, this.data.total_page = 0, this.isLoadMore = !0;
    },
    getList: function() {
        var a = this, e = "";
        0 == this.data.active ? e = "plugin.store-attendance.frontend.member.detailed" : 1 == this.data.active ? e = "plugin.store-attendance.frontend.member.record" : 2 == this.data.active && (e = "plugin.store-attendance.frontend.member.withdraw");
        var i = t.getNetAddresss(e);
        t._getNetWork({
            url: i,
            data: {
                page: this.data.page
            },
            success: function(t) {
                var e = t.data;
                1 == e.result ? (a.data.isLoadMore = !0, a.data.total_page = e.data.last_page, a.data.total_page || (a.data.total_page = 0), 
                a.setData({
                    list: e.data
                })) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    tapinp: function(t) {
        this.setData({
            points: t.detail.value
        });
    },
    withdrawablePoints: function() {
        var a = this;
        if (t._isTextEmpty(this.data.points)) t.tips("请输入打卡分"); else if (this.data.points > this.data.info.withdraw_points) t.tips("输入打卡分大于可提现打卡分"); else {
            var e = t.getNetAddresss("plugin.store-attendance.frontend.member.withdrawablePoints");
            t._getNetWork({
                url: e,
                data: {
                    points: this.data.points
                },
                success: function(e) {
                    var i = e.data;
                    1 == i.result ? (t.tips(i.msg), a.setData({
                        show: !1,
                        points: ""
                    }), a.getData()) : wx.showToast({
                        icon: "none",
                        title: i.msg,
                        duration: 1500
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    getData: function() {
        var a = this, e = t.getNetAddresss("plugin.store-attendance.frontend.member.index");
        t._getNetWork({
            url: e,
            success: function(t) {
                var e = t.data;
                1 == e.result ? a.setData({
                    info: e.data.statistics,
                    withdraw_type: e.data.withdraw_type
                }) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    changeTap: function(t) {
        var a = t.detail.index;
        this.setData({
            active: a
        }), this.initPage(), this.getList();
    },
    showClose: function() {
        this.setData({
            show: !1
        });
    },
    showTap: function() {
        this.setData({
            show: !0
        });
    },
    onReady: function() {},
    onShow: function() {
        this.initPage(), this.getData(), this.getList();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    getMoreData: function() {
        var a = this, e = "";
        this.data.isLoadMore = !1, this.data.page >= this.data.total_page || (this.data.page = this.data.page + 1, 
        0 == this.data.active ? e = t.getNetAddresss("plugin.store-attendance.frontend.member.detailed") : 1 == this.data.active ? e = t.getNetAddresss("plugin.store-attendance.frontend.member.record") : 2 == this.data.active && (e = t.getNetAddresss("plugin.store-attendance.frontend.member.withdraw")), 
        t._getNetWork({
            url: e,
            data: {
                page: this.data.page
            },
            success: function(t) {
                var e = t.data;
                1 == e.result ? (a.data.isLoadMore = !0, a.setData({
                    list: e.data
                })) : (a.data.page = a.data.page - 1, a.isLoadMore = !1, wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                }));
            },
            fail: function(t) {
                console.log(t);
            }
        }));
    },
    onShareAppMessage: function() {}
});